package creative.fire.interview.oracle;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;

/**
 * @author feuyeux@gmail.com 2011-10-13
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
public class RemoveDuplicateLinkedList {
	LinkedList inputList = new LinkedList();

	public static void main(String[] args) {
		RemoveDuplicateLinkedList thiz = new RemoveDuplicateLinkedList();
		thiz.init();
		thiz.usingHashSet();
	}

	private void usingHashSet() {
		HashSet set = new HashSet(inputList);
		LinkedList result = new LinkedList(set);
		Iterator t = result.iterator();

		while (t.hasNext()) {
			System.out.println(t.next());
		}
	}

	private void init() {
		Integer[] data = new Integer[] { 2, 4, 5, 6, 3, 5, 2, 3 };
		inputList.addAll(Arrays.asList(data));
	}
}
